package com.linkage.jz.bankruptcy.activity.Project;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.linkage.jz.bankruptcy.R;
import com.linkage.jz.bankruptcy.base.BaseActivity;
import com.linkage.jz.bankruptcy.bean.ProPublic;
import com.seapeak.recyclebundle.BaseHolder;
import com.seapeak.recyclebundle.BaseRecyclerAdapter;

import java.util.ArrayList;
import java.util.List;

import cn.bingoogolapple.swipeitemlayout.BGASwipeItemLayout;


public class ProPublicViewMemberActivity extends BaseActivity {
    public static final String KEY_PUBLIC = "KEY_PUBLIC";

    private ProPublic mPublicDetail;


    private ArrayList<ProPublic.MemberBean> mData = new ArrayList<>();
    private RecyclerView mRecyclerView;
    private ConversationAdapter mAdapter;
    private TextView tv_num;

    @Override
    public void initData() {

    }

    @Override
    public void setListener() {

    }

    @Override
    public void initTitle() {

    }

    @Override
    public void initView() {

    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        setContentView(R.layout.activity_pro_public_view_member);
        super.onCreate(savedInstanceState);
        titlebar_title.setText("人员详情");

        mPublicDetail = (ProPublic) getIntent().getSerializableExtra(KEY_PUBLIC);

        mData.addAll(mPublicDetail.getMemberList());

        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
        mRecyclerView = findViewById(R.id.recyclerView);
        mRecyclerView.setLayoutManager(linearLayoutManager);
        mAdapter = new ConversationAdapter(this, mData);
        mRecyclerView.setAdapter(mAdapter);

        tv_num = findViewById(R.id.tv_num);
        tv_num.setText("人数：" + mData.size() + "人");
    }

    class ConversationAdapter extends BaseRecyclerAdapter<ConversationAdapter.ItemViewHolder> {

        private Context context;

        public ConversationAdapter(Context context, List<ProPublic.MemberBean> mDataList) {
            this.context = context;
        }

        @NonNull
        @Override
        public ConversationAdapter.ItemViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int type) {
            View v = LayoutInflater.from(context).inflate(R.layout.activity_pro_public_view_member_item, viewGroup, false);


            return new ConversationAdapter.ItemViewHolder(v);
        }

        @Override
        public void onBindViewHolder(final ConversationAdapter.ItemViewHolder holder, final int position) {
            super.onBindViewHolder(holder, position);
            final ProPublic.MemberBean person = mData.get(position);
            holder.tv_name.setText(person.getCreditorName());


        }

        @Override
        public int getItemCount() {
            return mData.size();
        }

        @Override
        public int getItemViewType(int position) {
            return 0;
        }

        class ItemViewHolder extends BaseHolder {

            public BGASwipeItemLayout silItemBgaswipeRoot;
            public ImageView avatar;
            public TextView tv_name;

            public ItemViewHolder(View view) {
                super(view);
                tv_name = view.findViewById(R.id.tv_name);
            }
        }
    }
}
